<?php 
class Tmenu extends AppModel {


	var $name = 'Tmenu';
	var $useTable = 'tmenu';
	var $primaryKey = "id";
	/**
     * get menu tree data
     *
     * @param int $pid parent id
     * @return array
     */
	function getSubMenu($pid = '0') {

		$res = $this->findAll("f_pid='$pid'", '', "f_order asc");

		$data = Array();
		if (count($res) > 0) {
			foreach ($res AS $val) {
				if (isset($val['Tmenu']) && ! empty($val['Tmenu'])) {
					$data_tmp = $val['Tmenu'];
					$data_tmp['sub'] = $this->getSubMenu($data_tmp['id']);
					//print $data_tmp['id']."\n";
					$data[] = $data_tmp;
					unset($data_tmp);
				}


			}
		}
		return $data;
	}
}
?>
